<script setup>
import { ref, onMounted } from 'vue';
import { useRouter } from 'vue-router';

const router = useRouter();

onMounted(() => {
  // 全局事件监听
  window.addEventListener('logout', handleLogout);
});

const handleLogout = () => {
  localStorage.removeItem('token');
  localStorage.removeItem('user');
  console.log('已登出');
  router.push('/login');
};
</script>

<template>
  <router-view />
</template>

<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

html, body {
  width: 100%;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

#app {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

.app-container {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.logout-btn {
  padding: 10px 15px;
  background-color: #f44336;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 20px;
}

.logout-btn:hover {
  background-color: #d32f2f;
}
</style>
